package com.example.design.bilibili.proxy.dynamicProxy;

/**
 * 动态代理
 */
public class Client {

    public static void main(String[] args) {
        //创建目标对象
        TeacherDao teacherDao = new TeacherDao();

        //给目标对象创建代理对象，可以装成ITeacherDao
        ITeacherDao proxy = (ITeacherDao) new ProxyFactory(teacherDao).getProxyInstance();

        //proxyInstance =com.sun.proxy.$Proxy0
        System.out.println("proxyInstance = "+proxy.getClass());

        proxy.teach();

        proxy.sayHello("你好");

    }
}
